<?
$typeId = $_GET['type'];
$brandId = $_GET['brand'];

$typeName = lookup_typeById($typeId);
$brandName = lookup_brandById($brandId);
?>

<script>
    jQuery(document).ready(function(){
	$('#filter_type').click(function() {
	    $('#filter_type_results').slideToggle(250);
	});
	
	$('#filter_brand').click(function() {
	    $('#filter_brand_results').slideToggle(250);
	});
    });
</script>


<div id="navigation">
    <h2>Filters</h2>
    <div>

	<table class="filterTable">
	    <thead>
		<tr>
		    <th class="filterLabel" id="filter_type"><div>Type of equipment</div><?= $typeName ?></th>
		    <th style="width: 26px;"><a href="browse_by_brand.php?brand=<?=$brandId?>"><img src="images/x.png" alt="Unfilter by type"/></a></th>

		</tr>
	    </thead>
	    </tbody></tbody>
	</table>
	
	<ul id="filter_type_results" class="filterResults">

	    <?
	    $types = array();
	    $types = getAllTypes();

	    foreach ($types as $type) {
		echo "<li><a href=\"browse.php?type=" . $type . "&&brand=" . $brandId . "\">";
		echo lookup_typeById($type);
		echo "</li></a>";
	    }
	    ?>
	</ul>

	<table class="filterTable" style="margin-top: 5px;">
	    <thead>
		<tr>
		    <th class="filterLabel" id="filter_brand"><div>Brand name</div><?= $brandName ?></th>
		    <th style="width: 26px;"><a href="browse_by_type.php?type=<?=$typeId?>"><img src="images/x.png" alt="Unfilter by brand"/></a></th>

		</tr>
		</thead>
		</tbody></tbody>
	</table>

	<ul id="filter_brand_results" class="filterResults">

	    <?
	    $brands = array();
	    $brands = getAllBrands();

	    foreach ($brands as $brand) {
		echo "<li><a href=\"browse.php?type=" . $typeId . "&&brand=" . $brand . "\">";
		echo lookup_brandById($brand);
		echo "</li></a>";
	    }
	    ?>
	</ul>

    </div>
</div>

